/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package shutdown;

import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.image.BufferedImage;
import java.util.ListResourceBundle;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;

/**
 *
 * @author Joel
 */
public class Run {

    public static final String REALKEY = "com.infinit.asd";

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {       
        writeKey();        
        Image img = Toolkit.getDefaultToolkit().createImage("ico2.jpg"); 
        AutoShutDown asd = new AutoShutDown(img);
        if (SystemTray.isSupported())
            try {
                SystemTray.getSystemTray().add(asd.getIcon());
                asd.getIcon().displayMessage("Auto Shutdown", "Ver1.7", TrayIcon.MessageType.NONE);
                System.out.println("Auto Shutdown Ver1.7\t" + AutoShutDown.currentTime("dd-MM-yyyy HH:mm:ss"));
            } catch (AWTException ex) {
                Logger.getLogger(Run.class.getName()).log(Level.SEVERE, null, ex);
                SwingIO.errorMsg("OS not supported!");
                }
        }

    private static void writeKey() {
        Preferences p = Preferences.userRoot();
        if (p.get(REALKEY, "Not here").equalsIgnoreCase("Not here")) 
            p.put(REALKEY, "Registered");
        else
            System.out.println("Already keyed");
        }
    }
